package com.ssm.utils;


//import sun.misc.BASE64Decoder;
//import sun.misc.BASE64Encoder;

import java.io.IOException;
import java.util.Base64;

/**
 * Base64加解密工具类
 * 备注：注释部分可在jdk1.8运行，jdk17不兼容
 */
public class Base64Util {

    /**
     * 加密
     *
     */
    public static String encryptBase64(byte[] bytes){
        //return (new BASE64Encoder()).encode(bytes);
        return Base64.getEncoder().encodeToString(bytes);
    }
    /**
     * 解密
     * @return
     */
    public static String decryBase64(String key) throws IOException {
        //return new String((new BASE64Decoder()).decodeBuffer(key));
        return new String(Base64.getDecoder().decode(key));
    }
}
